<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <h1>登录页面</h1>
  <div>
    用户名：<input type="text" id="username">
    <br>
    密码：<input type="text" id="password">
    <br>
    手机号：<input type="text" id="phone">
    <button id="loginBtn">登录</button>
  </div>
  <script src="http://127.0.0.1:3000/javascripts/jquery-3.4.1.min.js"></script>
  <script>

    $("#loginBtn").click(function () {
      $.ajax({
        url: "http://127.0.0.1:3000/users/login",
        type: "post",
        dataType: "json",
        data: {
          username: $("#username").val(),
          password: $("#password").val(),
          phone: $("#phone").val()
        },
        success: function (res) {
          console.log(res)
          // 将登录成功后返回的token存在存储中
          localStorage.token = res.token;
        }
      })
    })


  </script>
</body>

</html>